import Facility from "../facility/Facility";
import BadgerHouse from "../facility/priveteFacility/BadgerHouse";
import { FacilityType } from "../info/GameEnum";
import { Location } from "../info/Predefine";
import GameManager from "../manager/GameManager";
import Player from "./Player";

const { ccclass, property } = cc._decorator;

@ccclass
export default class BadgerPlayer extends Player {

    public get playerName(): string {
        return "平头哥之家"
    }

    public get flyerParentNode(): cc.Node {
        return GameManager.instance.underFlyerParent;
    }

    public get facilityHpColor(): cc.SpriteFrame {
        return GameManager.instance.enemyHpColors[0];
    }

    public get flyerhpColor(): cc.SpriteFrame {
        return GameManager.instance.enemyHpColors[1];
    }


    public set showAllView(v: boolean) { }
    public isLocationVisible(location: Location): boolean { return false }
    public isFacilityVisible(location: Facility): boolean { return false }
    public loseDomain(domain: Location[]): void { return }

    public onGetNewDomain(newDomain: Location[]): void { }
    public getLocationView(location: Location): void { }
    protected onFindNewEnemy(player: Player): void { }

    init() {
        this.facilityArr = [];
        this.facilityArr[FacilityType.平头哥之家] = [];
        this.props = [];
        this.props.length = 18;
        this.props.fill(0);
        /**
        * 每隔固定时间，派遣所有平头哥
        */
        this.schedule(() => {
            this.facilityArr[FacilityType.平头哥之家].forEach((badgerHouse: BadgerHouse) => {
                badgerHouse.autoDispatchAll();
            })
        }, 300);
        this.node.parent = this.node.parent;

        cc.director.on(cc.Director.EVENT_BEFORE_SCENE_LAUNCH, () => {
            this.unscheduleAllCallbacks();
            this.destroy();
            cc.director.targetOff(this)
        }, this);
    }
}
